#include "aed_particlesystemcomp.h"



AED_ParticleSystemComp::AED_ParticleSystemComp():m_totalparticles(0),m_lifetime(0),m_particle_lifetime(0),m_particle_velocity(0),
    m_randomness(0),m_autokill(0),m_autostart(1),m_loop(0),m_particle_size(1),m_interval(1),m_fading(0),m_animate(0),m_scaling(0),m_rotate_particles(1),m_velocity_interpolation(0)
{
    m_enabled=false;


}


AED_ParticleSystemComp& AED_ParticleSystemComp::operator =(const AED_ParticleSystemComp &comp){
    m_enabled = comp.m_enabled;
    m_particle = comp.m_particle;
    m_totalparticles = comp.m_totalparticles;
    m_lifetime = comp.m_lifetime;
    m_particle_lifetime = comp.m_particle_lifetime;
    m_particle_velocity = comp.m_particle_velocity;
    m_particle_size = comp.m_particle_size;
    m_randomness = comp.m_randomness;
    m_fading = comp.m_fading;
    m_scaling = comp.m_scaling;
    m_animate = comp.m_animate;
    m_rotate_particles = comp.m_rotate_particles;
    m_velocity_interpolation = comp.m_velocity_interpolation;
    m_autostart = comp.m_autostart;
    m_autokill = comp.m_autokill;
    m_loop = comp.m_loop;
    m_interval = comp.m_interval;

    return *this;
}

void AED_ParticleSystemComp::Save(QTextStream &file){
    if(!m_enabled)
        return;

    file << "   <component = ParticleSystem>" << endl;
    file << "      <particle = " << m_particle << ">" << endl;
    file << "      <total_particles = " << m_totalparticles << ">" << endl;
    file << "      <interval = " << m_interval << ">" << endl;
    file << "      <lifetime = " << m_lifetime << ">" << endl;
    file << "      <particle_lifetime = " << m_particle_lifetime << ">" << endl;
    file << "      <particle_velocity = " << m_particle_velocity << ">" << endl;
    file << "      <particle_size = " << m_particle_size << ">" << endl;
    file << "      <randomness = " << m_randomness << ">" << endl;
    file << "      <rotate_particles = " << m_rotate_particles << ">" << endl;
    file << "      <autostart = " << m_autostart << ">" << endl;
    file << "      <autokill = " << m_autokill << ">" << endl;
    file << "      <loop = " << m_loop << ">" << endl;
    file << "      <animate = " << m_animate << ">" << endl;
    file << "      <fading = " << m_fading << ">" << endl;
    file << "      <scaling = " << m_scaling << ">" << endl;
    file << "      <velocity_interpolation = " << m_velocity_interpolation << ">" << endl;
    file << "   </component>" << endl;

}

void AED_ParticleSystemComp::Save(QDomDocument &doc, QDomElement &pelem){
    if(!m_enabled)
        return;
    QDomElement elem = doc.createElement("component");
    elem.setAttribute("comptype","ParticleSystem");
    elem.setAttribute("particle",m_particle);
    elem.setAttribute("total_particles",m_totalparticles);
    elem.setAttribute("interval",m_interval);
    elem.setAttribute("lifetime",m_lifetime);
    elem.setAttribute("particle_lifetime",m_particle_lifetime);
    elem.setAttribute("particle_velocity",m_particle_velocity);
    elem.setAttribute("particle_size",m_particle_size);
    elem.setAttribute("randomness",m_randomness);
    elem.setAttribute("rotate_particles",m_rotate_particles);
    elem.setAttribute("autostart",m_autostart);
    elem.setAttribute("autokill",m_autokill);
    elem.setAttribute("loop",m_loop);
    elem.setAttribute("animate",m_animate);
    elem.setAttribute("fading",m_fading);
    elem.setAttribute("scaling",m_scaling);
    elem.setAttribute("velocity_interpolation",m_velocity_interpolation);
    pelem.appendChild(elem);
}

void AED_ParticleSystemComp::Load(QDomElement &celem){
    m_enabled = true;
    m_particle = celem.attribute("particle");
    m_totalparticles = celem.attribute("total_particles").toInt();
    m_interval = celem.attribute("interval").toInt();
    m_lifetime = celem.attribute("lifetime").toInt();
    m_particle_lifetime = celem.attribute("particle_lifetime").toInt();
    m_particle_velocity = celem.attribute("particle_velocity").toFloat();
    m_particle_size = celem.attribute("particle_size").toFloat();
    m_randomness = celem.attribute("randomness").toInt();
    m_rotate_particles = celem.attribute("rotate_particles").toInt();
    m_autostart = celem.attribute("autostart").toInt();
    m_autokill = celem.attribute("autokill").toInt();
    m_loop = celem.attribute("loop").toInt();
    m_animate = celem.attribute("animate").toInt();
    m_fading = celem.attribute("fading").toInt();
    m_scaling = celem.attribute("scaling").toFloat();
    m_velocity_interpolation = celem.attribute("velocity_interpolation").toFloat();
}

